# lua 脚本语言 保存红包信息

local listKey = 'red_paper_list_'..KEYS[1]

local redPaper = 'red_paper_'..KEYS[1]

local smSupCount = tonumber(redis.call('hget',redPaper,'smSupCount'))

if smSupCount <= 0 then return 0 end

smSupCount = smSupCount - 1

redis.call('hset', redPaper, 'smSupCount', tostring(smSupCount))

redis.call('rpush', listKey, ARGV[1])

if smSupCount == 0 then return 2 end

return 1